package components.dialogs
{
	import UIFree.uif_component;
	
	import classes.Commands.c_applyFilterCommand;
	import classes.c_util;
	
	import components.editor.c_baseElement;
	
	import flash.filters.BevelFilter;
	import flash.filters.BitmapFilter;
	import flash.filters.BitmapFilterQuality;
	
	public class c_filterPropDlg extends c_elementPropDlg {
		private var _filter: BitmapFilter;
		public function c_filterPropDlg(parent:uif_component, a_element:c_baseElement, a_title:String='', modal:Boolean=false, canClose:int=2) {
			_filter = c_util.findFilter(a_element, filterClass()) as BitmapFilter;
			if (!_filter) {
				_filter = new (filterClass())();
				if (_filter.hasOwnProperty('quality'))
					(_filter as Object).quality = BitmapFilterQuality.HIGH;
			}
			
			super(parent, a_element, propertyList(), a_title, modal, canClose);
		}
		
		protected function propertyList(): Array {
			return [];
		}
		
		protected function filterClass(): Class {
			return BitmapFilter;
		}
		
		protected function get filter(): BitmapFilter {
			return _filter;
		}
		
		override protected function updateElement(): void {
			element.applyFilter(_filter);
		}
		
		override protected function doCancel():void {
			element.removeFilter(_filter);
		}
		
		override protected function doApply():void {
			executeCommand(new c_applyFilterCommand(element, _filter));
		}		
	}
}